#! /bin/sh

export JAVA_HOME="/usr/java/jdk1.8.0_20"
export MAVEN_HOME="/work/resources/apache-maven-3.3.3"
export PATH=$PATH:$MAVEN_HOME/bin:$JAVA_HOME/bin
echo '基本环境变量配置成功...'

export CATALINA_BASE="$PWD"
echo '正在使用CATALINA_BASE='$CATALINA_BASE

export CATALINA_HOME="/work/tomcat"
echo '正在使用CATALINA_HOME='$CATALINA_HOME

export JAVA_OPTS="-Xms128m -Xmx512m --XX:PermSize=128m --XX:MaxPermSize=256m"
echo '正在使用JVM_OPTIONS='$JVM_OPTIONS

start=$CATALINA_HOME/bin/startup.sh
stop=$CATALINA_HOME/bin/shutdown.sh

start(){
       echo -n 'Staring Tomcat:'
       ${start}       
       echo 'Tomcat start ok.'
}

stop(){
      echo -n 'Shutting down Tomcat:'
      ${stop}
      echo 'tomcat stop ok.'
}

case $1 in
	start)
	    start
	;;
        stop)
            stop
	;;
        restart)
            stop
            sleep 10
            start
        ;;
	*)
        echo 'Usage:$0{start|stop|restart}'
esac
exit 0

